//
//  NSBundle+Extension.swift
//  WeiBo
//
//  Created by 张德华 on 7/24/16.
//  Copyright © 2016 ZhangDeHua. All rights reserved.
//

import Foundation

extension NSBundle {
    
    class var wq_currentVersion: String {
        
        guard let currentVersion = NSBundle.mainBundle().infoDictionary?["CFBundleShortVersionString"] as? String else {
            
            return "000.000.000"
        }
        
        
        ///------ 拆分字符串
        let strs = currentVersion.componentsSeparatedByString(".")
        var array: [CVarArgType] = [0,0,0]
        
        ///------ 遍历数组,生成临时数组
        for e in strs.enumerate() {
            array.insert(Int(e.element) ?? 0, atIndex: e.index)
        }
        
        ///------ 格式化字符串  001.002.003
        return String(format: "%03d.%03d.%03d", arguments:array)
        
    }
    
    
}